﻿#region Copyright (c) 2011, thinktecture (http://www.thinktecture.com)

/*
   thinktecture.UIAnnotations was developed by Jörg Neumann.
   Copyright (c) 2011, thinktecture (http://www.thinktecture.com).
   All rights reserved, comes as-is and without any warranty. Use of this
   source file is governed by the license which is contained in LICENSE.TXT 
   in the distribution.
*/

#endregion

using System;
using System.Linq;
using System.Windows;
using System.Collections.Generic;

namespace Thinktecture.UIAnnotations
{
    public class DataTypeDescriptor
    {
        public DataTypeDescriptor(Type elementType)
        {
            this.ElementType = elementType;
            this.PropertyDescriptors = new DataPropertyDescriptorCollection();
        }
        public Type ElementType { get; set; }
        public DataPropertyDescriptorCollection PropertyDescriptors { get; internal set; }
    }

    public class DataPropertyDescriptorCollection :  List<DataPropertyDescriptor>
    {
        public DataPropertyDescriptor this[string propertyName]
        {
            get
            {
                return (from p in this
                        where p.PropertyName.Equals(propertyName)
                        select p).FirstOrDefault();
            }
        }
    }

    public class DataPropertyDescriptor
    {
        public DataPropertyDescriptor(string propertyName, Type propertyType)
        {
            this.PropertyName = propertyName;
            this.PropertyType = propertyType;
            this.IsVisible  = true;
            this.IsReadOnly  = false;
            this.IsRequired  = false;
            this.DisplayName  = PropertyName;
            this.Description  = string.Empty;
            this.CueBannerText  = string.Empty;
            this.FormatString  = string.Empty;
            this.StringLength = System.Int32.MaxValue;
        }
        public string PropertyName { get; set; }
        public Type PropertyType { get; set; }
        public bool IsVisible { get; set; }
        public bool IsReadOnly { get; set; }
        public bool IsRequired { get; set; }
        public string DisplayName { get; set; }
        public string Description { get; set; }
        public string CueBannerText { get; set; }
        public string FormatString { get; set; }
        public int StringLength { get; set; }
        public string AssociationName { get; set; }
        public string AssociationThisKey { get; set; }
        public string AssociationOtherKey { get; set; }
        public FrameworkElement Control { get; set; }
    }
}
